import React from 'react';
import { EmailField, List, Edit, Create, Datagrid, ReferenceField, TextField, EditButton, DeleteButton,DisabledInput, LongTextInput, ReferenceInput, SelectInput, SimpleForm, TextInput } from 'react-admin';

export const SysPermissionList = (props) => (
    <List title="All Permissions" 
        sort={{ field: 'permissionName', order: 'ASC' }}
         {...props}>
        <Datagrid>
            <TextField source="menuCode" />
            <TextField source="menuName" />
            <TextField source="permissionCode" />
            <TextField source="permissionName" />

            <EditButton />
            <DeleteButton />
        </Datagrid>
    </List>
);

export const SysPermissionCreate = (props) => (
    <Create {...props}>
        <SimpleForm>
            <TextInput source="menuCode" />
            <TextInput source="menuName" />
            <TextInput source="permissionCode" />
            <TextInput source="permissionName" />
        </SimpleForm>
    </Create>
);

const PostTitle = ({ record }) => {
    return <span>Update {record ? `"${record.permissionName}"` : ''}</span>;
};

export const SysPermissionEdit = (props) => (
    <Edit title={<PostTitle />}  {...props}>
        <SimpleForm>
            <TextInput source="menuCode" />
            <TextInput source="menuName" />
            <TextInput source="permissionCode" />
            <TextInput source="permissionName" />
        </SimpleForm>
    </Edit>
);